﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 养老金支付系统
{
    class PPS
    {
        public static string Cookies { get; set; }
        public static int ZFHJ { get; set; }
        public static string ZFQH { get; set; }
        public static string InputPath
        {
            get { return Properties.Settings.Default.InputPath; }
            set
            {
                Properties.Settings.Default.InputPath = value;
                Properties.Settings.Default.Save();
            }
        }
        public static string OutputPath
        {
            get { return Properties.Settings.Default.OutPath; }
            set
            {
                Properties.Settings.Default.OutPath = value;
                Properties.Settings.Default.Save();
            }
        }
        /// <summary>
        /// 银行卡号有效性校验
        /// </summary>
        /// <param name="cardNumber">19位卡号</param>
        /// <returns>是否有效</returns>
        public static bool IsCardNumberValid(string cardNumber)
        {
            int i, checkSum = 0;

            // Compute checksum of every other digit starting from right-most digit
            for (i = cardNumber.Length - 1; i >= 0; i -= 2)
                checkSum += (cardNumber[i] - '0');

            // Now take digits not included in first checksum, multiple by two,
            // and compute checksum of resulting digits
            for (i = cardNumber.Length - 2; i >= 0; i -= 2)
            {
                int val = ((cardNumber[i] - '0') * 2);
                while (val > 0)
                {
                    checkSum += (val % 10);
                    val /= 10;
                }
            }

            // Number is valid if sum of both checksums MOD 10 equals 0
            return ((checkSum % 10) == 0);
        }
    }
}
